// components/authorization/index.js
Component({
  data: {
    isLogin: false,
  },
  lifetimes: {
    attached() {
      const isLogin = !!getApp().token
      this.setData({
        isLogin,
      })
      //获取页面栈
      const pageStack = getCurrentPages()
      const currentpage = pageStack.pop()
      if (!isLogin) {
        currentpage.onLoad = () => {}
        currentpage.onShow = () => {}
        wx.redirectTo({
          url: '/pages/login/index?redirectURL=/' + currentpage.route,
        })
      }
    },
  },
})
